﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sripirom.Pattern.UnitTest.Core.Domain;

namespace Sripirom.Pattern.UnitTest.Model.TestCases
{
    public class UnitTestCategory  : BaseEntity<String>, IAggregateRoot
    {
        private IList<UnitTestClass> _testClasses;
        public UnitTestCategory(IList<UnitTestClass> testClasses)
        {
            _testClasses = testClasses;
        }
        public UnitTestCategory()
        {
            _testClasses = new List<UnitTestClass>();
        }

        public String Name { get; set; }

        public IEnumerable<UnitTestClass> TestClasses { get { return _testClasses; } }

        public void AddClass(UnitTestClass clazz) 
        {
            _testClasses.Add(clazz);
        }
        public void RemoveClass(UnitTestClass testClass)
        {
            UnitTestClass removeClazz = _testClasses.FirstOrDefault(a => a == testClass);
            if (removeClazz == null)
                throw new ArgumentOutOfRangeException("Class not found.");

            _testClasses.Remove(removeClazz); 
        }
        protected override void Validate()
        {
            throw new NotImplementedException();
        }
    }

    public interface IUnitTestCategoryRepository : IRepository<UnitTestCategory, String> { }
}
